import os
import sys
import plugin

import util

PLUGIN_NAME = "quit"

class Quit(util.ParentPlugin):
    def __init__(self, parent, path, name):
        util.ParentPlugin.__init__(self,parent,path,name)

    def stop(self,args=None):
        webui_service = util.service("webui")
        webui_service.stop()
        self.post((util.QUIT,""))
        return 1


def start(server,parent):
    quit_plugin = Quit(parent,__file__,PLUGIN_NAME)
    server.connect(quit_plugin,PLUGIN_NAME)
    util.load_plugins(server,quit_plugin,None,container = parent)
    plugin.update_state(PLUGIN_NAME,plugin.STARTED)
        
